package com.baibei.model;

import android.os.Parcel;

import com.google.gson.annotations.SerializedName;

/**
 * 排行榜信息
 * Created by ChenRui on 2017/8/9 0009 17:41.
 */
public class RankingInfo extends ProductInfo {

    @SerializedName("closePrice")
    private double close;
    private long estimateTime;
    private String saleTips;
    private double openPrice;

    public String getSaleTips() {
        return saleTips;
    }

    public void setSaleTips(String saleTips) {
        this.saleTips = saleTips;
    }

    public double getClose() {
        return close;
    }

    public void setClose(double close) {
        this.close = close;
    }


    @Override
    public String toString() {
        return "RankingInfo{" +
                "close=" + close +
                ", estimateTime=" + estimateTime +
                ", saleTips='" + saleTips + '\'' +
                '}';
    }

    public long getEstimateTime() {
        return estimateTime;
    }

    public void setEstimateTime(long estimateTime) {
        this.estimateTime = estimateTime;
    }

    /**
     * 增长率（涨幅）
     */
    public double getScopePercent() {
        if (getLastPrice() == 0) return 0; // 被除数不能为零
        return ((getLastPrice() * 1.0f - close * 1.0f) / close * 1.0f);
    }

    /**
     * 增长量
     */
    public double getScope() {
        return (getLastPrice() - close) / 100.00d;
    }

    public RankingInfo() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        super.writeToParcel(dest, flags);
        dest.writeDouble(this.close);
        dest.writeLong(this.estimateTime);
        dest.writeString(this.saleTips);
    }

    protected RankingInfo(Parcel in) {
        super(in);
        this.close = in.readDouble();
        this.estimateTime = in.readLong();
        this.saleTips = in.readString();
    }

    public static final Creator<RankingInfo> CREATOR = new Creator<RankingInfo>() {
        @Override
        public RankingInfo createFromParcel(Parcel source) {
            return new RankingInfo(source);
        }

        @Override
        public RankingInfo[] newArray(int size) {
            return new RankingInfo[size];
        }
    };
}
